import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store/store'
import * as types from '../store/types'

import Login from '@/loginTest'
import LoginPublic from '@/loginDemo'
import Logout from '@/logout'
import wechatLogin from '@/wechatlogin'
import Welcome from '@/welcome'
import UserInfo from '@/user_info'
import firApp from '@/firApp'


import ChangePassword from '@/change_passwordUpd'

import Index from '@/components/index'
import IndexTeacher from '@/components/index_teacher'
import TeacherInfo from '@/components/teacher_info'
import ClassLog from '@/components/class_log'
import Student from '@/components/student'
import elective_teaEva from '@/components/elective_teaEva.vue'
import Teacher from '@/components/teacher'
import RollCall from '@/components/rollCall'
import Sign from '@/components/sign'
import Tag from '@/components/tag'
import Survey from '@/components/survey'
import Commissary from '@/components/commissary'
import commissaryWad from '@/components/commissary_wad'
import ClassInfo from '@/components/class_info'
//import Attendance from '@/components/attendance_update2'
import Attendance from '@/components/attendance_update2'
import AttendanceWad from '@/components/attendance_wad'
import teacherAttendance from '@/components/teacher_attendance'
import crystalBall from '@/components/crystal_ball'
import PersonalInfo from '@/components/personal_info'
import bindAccount from '@/components/bind_account'
import probFeedback from '@/components/problem_feedback'
import Feeling from '@/components/feeling'
import ClearCache from '@/components/clear_cache'
import ttk from '@/components/ttk'
import zk from '@/components/zk'
import tzzx from '@/components/tzzx'
import tznr from '@/components/tznr'
import noticeContent from '@/components/notice_content'
import Schedule from '@/components/schedule'
import ScheduleTeacher from '@/components/schedule_teacher'
import ClassTest from '@/components/class_test'
import ImproveInfo from '@/components/ImproveInfo'
import CommissaryBefore from '@/components/commissary_before'
import tabToggole from '@/components/test/tab_toggole'


/***
 * 新的import  LPH 2017/11/22
 */
import CourseFeedback from '@/components/CourseFeedback.vue'
import ReportCourseFeedback from '@/components/ReportCourseFeedback.vue'
import ReportCourseFeedbackImageDetail from '@/components/ReportCourseFeedbackImageDetail.vue'

/***
 * 问答  LPH 2018/4/3
 */
import qaIndex from '@/page/QA/qaIndex.vue'
import answer from '@/page/QA/answer.vue'
import subject from '@/page/QA/subject.vue'
import rank from '@/page/QA/rank.vue'
import rankSubject from '@/page/QA/rankSubject.vue'
/***
 * 九宫格秘钥考勤
 */
import setKey from '@/page/attendance/setKey.vue'
import signIn from '@/page/attendance/signIn.vue'
/***
 * 老师模块
 */

import teacherEcharts from '@/page/teacher/echarts'
import teacherEchartsIndex from '@/page/teacher/echartsIndex'

Vue.use(VueRouter)

const routes = [

  {
    path: '/',
    name: 'firApp',
    meta: {
      requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
    },
    component: firApp,
    children: [
      {
        path: '/qaIndex',
        name: 'qaIndex',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: qaIndex
      },
      {
        path: '/rankSubject',
        name: 'rankSubject',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: rankSubject
      },
      {
        path: '/rank',
        name: 'rank',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: rank
      },
      {
        path: '/subject',
        name: 'subject',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: subject
      },
      {
        path: '/answer',
        name: 'answer',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: answer
      },
      
      {
        path: '/user-info',
        name: 'UserInfo',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: UserInfo
      },
      {
        path: '/index',
        name: 'index',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Index,
      },
      {
        path: '/index_teacher',
        name: 'indexTeacher',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: IndexTeacher,
      },
      {
        path: '/teacher_info',
        name: 'teacherInfo',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: TeacherInfo,
      },
      {
        path: '/crystal_ball',
        name: 'crystalBall',
        component: crystalBall
      },{
        path: '/electiveCourseEvaluation',
        name: 'electiveCourseEvaluation',
        component: elective_teaEva
      }, {
        path: '/schedule',
        name: 'Schedule',
        component: Schedule
      }, {
        path: '/schedule_teacher',
        name: 'ScheduleTeacher',
        component: ScheduleTeacher
      }, {
        path: '/feeling',
        name: 'Feeling',
        component: Feeling
      }, {
        path: '/clear-cache',
        name: 'ClearCache',
        component: ClearCache
      },{
        path: '/improve_info',
        name: 'ImproveInfo',
        component: ImproveInfo
      },{
        path: '/classTest',
        name: 'classTest',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: ClassTest
      }, {
        path: '/ChangePassword',
        name: 'ChangePassword',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: ChangePassword
      }, {
        path: '/personal-info',
        name: 'PersonalInfo',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: PersonalInfo
      },
      {
        path: '/bind-account',
        name: 'bindAccount',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: bindAccount
      },
      {
        path: '/problem-feedback',
        name: 'probFeedback',
        component: probFeedback
      },
//		    {
//		      path: '/index',
//		      name: 'Index',
//		      meta: {
//		        requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
//		      },
//		      component: Index
//		    },
      {
        path: '/class_log',
        name: 'ClassLog',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: ClassLog
      }, {
        path: '/attendance',
        name: 'Attendance',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Attendance
      },{
        path: '/AttendanceWad',
        name: 'AttendanceWad',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: AttendanceWad
      }, {
        path: '/rollCall',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: RollCall
      },{
        path: '/teacherAttendance',
        name:'teacherAttendance',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: teacherAttendance
      },{
        path: '/sign',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Sign
      }, {
        path: '/student',
        name: 'Student',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Student
      }, {
        path: '/teacher',
        name: 'Teacher',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Teacher
      }, {
        path: '/tag',
        name: 'Tag',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Tag
      }, {
        path: '/tabToggole',
        name: 'tabToggole',
        component: tabToggole
      }, {
        path: '/survey',
        name: 'Survey',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Survey
      }, {
        path: '/commissary',
        name: 'Commissary',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: Commissary
      }, {
        path: '/commissaryWad',
        name: 'commissaryWad',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: commissaryWad
      }, {
        path: '/commissary_before',
        name: 'CommissaryBefore',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: CommissaryBefore
      },{
        path: '/ttk',
        name: 'ttk',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: ttk
      }, {
        path: '/zk',
        name: 'zk',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: zk
      }, {
        path: '/class_info',
        name: 'ClassInfo',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: ClassInfo
      }, {
        path: '/tzzx',
        name: 'tzzx',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: tzzx
      }, {
        path: '/tznr/:bh',
        name: 'tznr',
        meta: {
          requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: tznr
      },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    //    meta: {
    //      title: '教学记载与评价系统',
    //    },
    component: Login
  }, 
  {
    path: '/LoginPublic',
    name: 'LoginPublic',
    //    meta: {
    //      title: '教学记载与评价系统',
    //    },
    component: LoginPublic
  }, 
  {
    path: '/logout',
    name: 'Logout',
    component: Logout
  },
  {
    path: '/wechatLogin',
    name: 'wechatLogin',
    component: wechatLogin
  },
  {
    path: '/notice-content/:bh',
    name: 'noticeContent',
    component: noticeContent
  },
  {
    path: '/setKey',
    name: 'setKey',
    component: setKey
  },
  {
    path: '/signIn',
    name: 'signIn',
    component: signIn
  },



  /**
   * 新增路由:   教学反馈
   */
  {
    path: '/courseFeedback',
    name: 'courseFeedback',
    component: CourseFeedback
  },
  {
    path: '/reportCourseFeedback',
    name: 'reportCourseFeedback',
    component: ReportCourseFeedback
  },
  {
    path: '/reportCourseFeedbackImageDetail',
    name: 'reportCourseFeedbackImageDetail',
    component: ReportCourseFeedbackImageDetail
  },
  
  
    /**
   * 老师的
   */
   {
    path: '/teacherEcharts',
    name: 'teacherEcharts',
    component: teacherEcharts
  },
      /**
   * 老师的统计页面首页
   */
   {
    path: '/teacherEchartsIndex',
    name: 'teacherEchartsIndex',
    component: teacherEchartsIndex
  }



];
if (window.localStorage.getItem('token')) {
    store.commit(types.LOGIN, window.localStorage.getItem('token'))
}
const router = new VueRouter({
  routes,
  history: true
});
//router.beforeEach((to, from, next) => {
//  if (to.matched.some(r => r.meta.requireAuth)) {
//      if (store.state.token) {
//          next();
//      }
//      else {
//          next({
//              path: '/login',
//              query: {redirect: to.fullPath}
//          })
//      }
//  }
//  else {
//      next();
//  }
//})
export default router;
